package com.xframe.xdal.core.annotation;



import java.util.Map;

public class XSelectItemCollect {

    public static final String OPTION_NAME = "label";
    public static final String OPTION_ID = "value";

    private Map<String,XSelectItemModel> selectItemModelMap;


    public static boolean isEmpty(XSelectItemCollect xSelectItemCollect){
        return xSelectItemCollect == null || xSelectItemCollect.selectItemModelMap == null || xSelectItemCollect.selectItemModelMap.size() == 0;
    }


    public XSelectItemCollect(Map<String,XSelectItemModel> selectItemModelMap){
        this.selectItemModelMap = selectItemModelMap;
    }


    public String getMapName(String language,String attrName){
        XSelectItemModel xSelectItemModel = this.selectItemModelMap.get(language);
        if(xSelectItemModel == null){
            return attrName;
        }
        if(xSelectItemModel.findKey(attrName)){
            return OPTION_ID;
        }
        if(xSelectItemModel.findName(attrName)){
            return OPTION_NAME;
        }
        return attrName;
    }

//    public XSelectItemModel getKeyFlag(){
//        for(XSelectItemModel item : this.selectItemList){
//            if(item.isKeyFlag()){
//                return item;
//            }
//        }
//        return null;
//    }
//
//    public XSelectItemModel getCodeFlag(){
//        for(XSelectItemModel item : this.selectItemList){
//            if(item.isCodeFlag()){
//                return item;
//            }
//        }
//        return null;
//    }
//
//    public XSelectItemModel getTextFlag(String language){
//        for(XSelectItemModel item : this.selectItemList){
//            if(item.isTextFlag() && item.getLanguage().equals(language)){
//                return item;
//            }
//        }
//        return null;
//    }
//
//    public XSelectItemModel getTextFlagByAttrName(String attrName){
//        for(XSelectItemModel item : this.selectItemList){
//            if(item.isTextFlag() && item.getAttrName().equals(attrName)){
//                return item;
//            }
//        }
//        return null;
//    }

}
